uniform float4x4 StateComplete;
uniform float4x4 StateWorld;
float3 eyePos = { 100, 100, 100 };
sampler2D tex0;
sampler2D tex1;

void vsMain(
			in float4 pos: POSITION, 
			out float4 opos: POSITION, 
			in float2 tc: TEXCOORD0, 
			out float2 otc: TEXCOORD0,
			in float3 normal: NORMAL,
			in float3 binormal: TEXCOORD2,
			in float3 tangent: TEXCOORD3,
			out float3 tangentEyeVec: TEXCOORD4
			)
{
	opos = mul(StateComplete, pos);
	otc = tc;

	float3 eyeVec = pos - eyePos;
	float3x3 worldToTangent = { binormal, tangent, normal };
	tangentEyeVec = mul(worldToTangent, eyeVec);

}

float4 psMain(
			  in float2 t: TEXCOORD0,
			  in float2 eye: TEXCOORD4,
			  in float3 normal: TEXCOORD1
			  ): COLOR
{
	float height = tex2D(tex1, t).x;
	eye = normalize(eye);
	t -= (height * 0.03-0.015) * float2(eye.x, eye.y);
	return tex2D(tex0, t);
}